package cn.wk.web;

import cn.wk.domain.SmsLoginVo;
import cn.wk.utils.StrUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

@RestController
public class SmsSendController {
    @PostMapping("/sms/send/{phone}")
    public void sendSms(@PathVariable("phone") String phone, HttpServletRequest request) {
        String code = UUID.randomUUID().toString().substring(0, 4);
        request.getSession().setAttribute("sms:code", new SmsLoginVo(phone, code, new Date().getTime()));
        System.out.println("手机验证码为：" + code);
    }
}
